<template>
  <div>
    <TopFilter :list="partMonthFilterList" :cols="3" :labelWidth="90" @filterChange="changeHandle"></TopFilter>
    <FilterTable
      ref="partTable"
      :columns="partMonthColumns"
      :isSelectColumn="false"
      :datakey="'rows'"
      :dataSource="listResult"
      :onColumnsChange="columns => this.partMonthColumns = columns"
    >
      <template slot="controls">
        <el-button size="small" type="primary">导出</el-button>
      </template>
    </FilterTable>
  </div>
</template>

<script>
import { dictionary } from '@/utils/dictMixin';
export default {
  name: 'partMonth',
  mixins: [dictionary],
  data() {
    this.BaseTable = null;
    return {
      partMonthFilterList: this.createPartFilterList(),
      // fetchApi:'',
      // fetchParams: { xhrAbort: false },
      partMonthColumns: this.createPartColumns()
    };
  },
  methods: {
  createPartFilterList() {
    return [
      {
        type: 'DATE',
        label: '会计年月',
        fieldName: 'funcYearMonth',
        valueFormat: 'yyyy-MM-dd'
      },
      {
        type: 'SELECT',
        label: '九大类',
        fieldName: 'partMainType',
        itemList: []
      }
    ];
  },
  createPartColumns() {
    return [
      {
        title: '序号',
        dataIndex: 'index',
        render: props => {
          return <span>{props.row.index + 1}</span>;
        }
      },
      {
        title: '报表年份',
        dataIndex: 'REPORT_YEAR',
        sorter: true
      },
      {
        title: '报表月份',
        dataIndex: 'REPORT_MONTH',
        sorter: true
      },

      {
        title: '仓库',
        dataIndex: 'STORAGE_CODE',
        sorter: true
      },
      {
        title: '配件代码',
        dataIndex: 'PART_NO',
        sorter: true,
      },
      {
        title: '配件名称',
        dataIndex: 'PART_NAME',
        sorter: true
      },
      {
        title: '九大类',
        dataIndex: 'PART_MAIN_TYPE',
        sorter: true
      },
      {
        title: '期初数量',
        dataIndex: 'OPEN_QUANTITY',
        sorter: true
      },
      {
        title: '期初单价',
        dataIndex: 'OPEN_PRICE',
        sorter: true
      },
      {
        title: '期初金额',
        dataIndex: 'OPEN_AMOUNT',
        sorter: true
      },
      {
        title: '入库数量',
        dataIndex: 'IN_QUANTITY',
        sorter: true
      },
      {
        title: '入库金额',
        dataIndex: 'STOCK_IN_AMOUNT',
        sorter: true
      },
      {
        title: '出库数量',
        dataIndex: 'OUT_QUANTITY',
        sorter: true
      },
      {
        title: '出库金额',
        dataIndex: 'OUT_AMOUNT',
        sorter: true
      },
      {
        title: '期末数量',
        dataIndex: 'CLOSE_QUANTITY',
        sorter: true
      },
      {
        title: '期末单价',
        dataIndex: 'CLOSE_PRICE',
        sorter: true
      },
      {
        title: '期末金额',
        dataIndex: 'CLOSE_AMOUNT',
        sorter: true
      }
    ];
  },
  changeHandle(val) {
    // console.log('val', val);
    // this.fetchParams = Object.assign({}, val, { xhrAbort: false });
  }
},
  mounted() {
    this.BaseTable = this.$refs.partTable.$refs.pageTable;
    let list={
        REPORT_YEAR:'2019',
        REPORT_MONTH:'02',
        STORAGE_CODE:'CSCK',
        PART_NO:'00003',
        PART_NAME:'PDI油',
        PART_MAIN_TYPE:'',
        OPEN_QUANTITY:1094.00,
        OPEN_PRICE:0.02,
        OPEN_AMOUNT:21.92,
        IN_QUANTITY:0.00,
        STOCK_IN_AMOUNT:0.00,
        OUT_QUANTITY:1.00,
        OUT_AMOUNT:0.02,
        CLOSE_QUANTITY:9.00,
        CLOSE_PRICE:10.00,
        CLOSE_AMOUNT:90.00
    }
    this.listResult=[list];
  }
};
</script>

<style scoped lang="less">
</style>
